import logging

from credit_voice_service.dialogue.factory.base_info.strategy.base_info_strategy import (
    BaseInfoStrategy,
)


class BaseInfoStrategy2132(BaseInfoStrategy):
    def get_base_info(self, session_id, user_info):
        # 名字 年龄  优惠券名称 权益 降息幅度 降息剩余天数 拨次 用户阶段 是否有88折券 额度是否可用 是否有提额机会 优惠券剩余天数 降息力度 提额力度
        name = ""
        age = ""
        account_state = ""
        try:
            name = user_info.get('fullName', '')
            sex = user_info.get('sexByChineseWord', '')
            if name and sex:
                name = name + sex
            else:
                name = ''
            age = user_info.get('ageRange', '')
            account_state = user_info.get("accountState", "")
        except Exception as e:
            logging.error("获取用户信息报错 报错信息:{} session_id:{}".format(str(e), session_id))
        finally:
            base_info = {"用户姓名": name, "用户年龄": str(age), "账户状态": account_state}
            logging.info(f"session_id:{session_id} 获取到用户信息:{base_info}")
            return base_info
